namespace ScrumSprintMonitor.ConfigEditor
{
	#region #using Directives

    using Implementation;
	using Implementation.Configuration;

	using Infrastructure;
	using Infrastructure.IoC;

    using Microsoft.Practices.Unity;

	using Views.ConfigurationView;
	using Views.PresentationConfigurationEditorView;
	using Views.SprintConfigurationEditorView;

	#endregion

    internal class UnityAppRuntimeModule : StandardModule
	{
		/// <summary>
        ///   Loads the module into the container.
		/// </summary>
		public override void Load()
		{
			Container.RegisterInstance<IUnityContainer>(Container);
            Container.RegisterType(typeof(ILogger<>), typeof(Log4netLogger<>));

			SetupRuntimeBindings();
		}

		private void SetupRuntimeBindings()
		{
            Container.RegisterType<IProcessTemplateAdapterProvider, MefProcessTemplateAdapterProvider>(new ContainerControlledLifetimeManager());
            Container.RegisterType<IConnectionProvider, ConnectionProvider>(new ContainerControlledLifetimeManager());

            Container.RegisterType<FileDataStreamProvider>();
            Container.RegisterType<StreamBasedSprintConfiguration>();

            Container.RegisterType<IConfigurationViewModel, ConfigurationViewModel>(new ContainerControlledLifetimeManager());
            Container.RegisterType<ISprintConfigurationEditorViewModel, SprintConfigurationEditorViewModel>();
            Container.RegisterType<IPresentationConfigurationEditorViewModel, PresentationConfigurationEditorViewModel>();
		}
	}
}